{{ $section := .Scratch.Get "section" }}
<div tabindex="1" class="sidebar-btn"></div>
<aside class="sidebar" id="sidebar">
  <nav>
    <ul>
      <li>
        <a href="{{ relURL "about" }}"{{ if (eq $section "about") }} class="active"{{ end }}>About</a>
        <ul{{ if (eq $section "about") }} class="expanded"{{ end }}>
          {{ if (eq $section "about") }}
          {{ $subsection := .Params.subsection }}
          {{ $abouts := sort (where .Site.RegularPages "Params.section" "about") "Params.order"  }}
          {{ range $i, $about := $abouts }}
            <li>
              <a href="{{ relURL (strings.TrimSuffix ".html" $about.RelPermalink) }}"{{ if (eq $.Params.subsection $about.Params.subsection) }} class="active"{{ end }}>{{ $about.Params.subtitle }}</a>
            </li>
          {{ end }}
          {{ end }}
        </ul>
      </li>
      <li>
        <a href="{{ relURL "doc" }}"{{ if (eq $section "documentation") }} class="active"{{ end }}>Documentation</a>
        <ul {{ if (eq $section "documentation") }}class="expanded"{{ end }}>
          <li>
            <a href="{{ relURL "docs" }}"{{ if or (eq .Params.Subsection "reference") (eq .Params.Subsection "manual") }} class="active"{{ end }}>Reference</a>
          </li>
          <li>
            <a href="{{ relURL "book" }}"{{ if (eq .Params.Subsection "book") }} class="active"{{ end }}>Book</a>
          </li>
          <li>
            <a href="{{ relURL "videos" }}"{{ if (eq .Params.Subsection "videos") }} class="active"{{ end }}>Videos</a>
          </li>
          <li>
            <a href="{{ relURL "doc/ext" }}"{{ if (eq .Params.Subsection "external-links") }} class="active"{{ end }}>External Links</a>
          </li>
        </ul>
      </li>
      <li>
        <a href="{{ relURL "downloads" }}"{{ if (eq $section "downloads") }} class="active"{{ end }}>Downloads</a>
        <ul {{ if (eq $section "downloads") }}class="expanded"{{ end }}>
          <li>
            <a href="{{ relURL "downloads/guis" }}"{{ if (eq .Params.Subsection "guis") }} class="active"{{ end }}>GUI Clients</a>
          </li>
          <li>
            <a href="{{ relURL "downloads/logos" }}"{{ if (eq .Params.Subsection "logos") }} class="active"{{ end }}>Logos</a>
          </li>
        </ul>
      </li>
      <li>
        <a href="{{ relURL "community" }}"{{ if (eq $section "community") }} class="active"{{ end }}>Community</a>
      </li>
    </ul>
    {{ if (eq .Params.Sidebar "book") }}
      <hr class="sidebar">
      {{- /* If this page displays a section of the ProGit book, map all the translations thereof */ -}}
      {{ with $.Page.Params.book }}
        {{ $cs_number := .section.cs_number }}
        {{ range $.Page.Site.Data.book }}
          {{ $language_code := .language_code }}
          {{ range .chapters }}
            {{ range .sections }}
              {{ if (eq .cs_number $cs_number) }}
                {{ $.Scratch.SetInMap "translations" $language_code .url }}
              {{ end }}
            {{ end }}
          {{ end }}
        {{ end }}
      {{ end }}
      {{ partial "translations.html" . }}
    {{ else if (and (ne $section "documentation") (ne $section "site")) }}
      <hr class="sidebar">
      {{ partial "book.html" }}
    {{ end }}
  </nav>
</aside>
